package enumType;

import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.Set;
import java.util.TreeSet;

import static tool.Print.print;

enum  Explore{HERE,THERE}
public class Reflection {
	public static Set<String> analyze(Class<?> enumClass){
		print("--------Analyzing "+enumClass + " -----");
		print("Interfaces");
		/*
		 * 获得implement的接口
		 */
		for(Type t:enumClass.getGenericInterfaces())
			print(t);
		//得到继承的类
		print("Base: " +enumClass.getSuperclass() );
		print("Methods: ");
		/*
		 * 获得实现的方法
		 */
		Set<String> methods =new TreeSet<>();
		for (Method m:enumClass.getMethods()) {
			methods.add(m.getName());
		}
		print(methods);
		return methods;
	}
	
	
	public static void main(String[] args){
		Set<String> exploreMethods = analyze(Explore.class);
		Set<String> enumMethods = analyze(Enum.class);
		print("Explore.containsAll(Enum)? " +exploreMethods.removeAll(enumMethods) );
		print(exploreMethods);
//		OSExecute.command("javap Explore");
	}
}
